<template>
  <Layout :info="userInfo" @logout="logout" :infos ="infos" logo="XXXXXXXXX平台">
    <router-view></router-view>
  </Layout>
</template>

<script>
import Layout from '@/view/layout/main'
import login from '@/view/layout/login'
export default {
  components: {
    Layout,
    login
  },
  data () {
    return {
      userInfo: { name: 'ziChin' },
      infos: []
    }
  },
  computed: {
    isLogin () {
      return this.$route.path === '/login'
    }
  },
  created () {
    let userInfo = sessionStorage.getItem('userInfo')
    console.log(userInfo)
    if (!userInfo) {
      this.$router.push('/login')
    } else {
      userInfo = JSON.parse(userInfo)
      this.userInfo = userInfo
      console.log(userInfo)
      this.initInfos()
    }
  },
  methods: {
    logout (v) {
      this.userInfo = null
      sessionStorage.removeItem('userInfo')
      this.$router.push('/login')
    },
    initInfos () {
      this.infos = [
        {
          name: 'home',
          label: '首页',
          icon: 'ios-people'
        },
        {
          name: 'userManage',
          label: '用户管理',
          icon: 'ios-people',
          hidden: this.userInfo.type === 0
        },
        // {
        //   name: '1',
        //   label: '用户管理',
        //   icon: 'ios-people',
        //   hidden: this.userInfo.type === 1,
        //   children: [
        //     {
        //       name: '1-1',
        //       label: '用户管理',
        //       icon: 'ios-people',
        //       children: [
        //         {
        //           name: 'userManage',
        //           label: '用户管理',
        //           icon: 'ios-people'
        //         },
        //         {
        //           name: 'kmlManage',
        //           label: '设计输入',
        //           icon: 'md-photos'
        //         },
        //         {
        //           name: 'contrastManage',
        //           label: '图标对比',
        //           icon: 'md-cloudy'
        //         }
        //       ]
        //     },
        //     {
        //       name: 'networkServerSystem',
        //       label: '网络系统图(单交接箱)',
        //       icon: 'md-photos'
        //     },
        //     {
        //       name: 'networkServerSystem2',
        //       label: '网络系统图(双交接箱)',
        //       icon: 'md-photos'
        //     }
        //   ]
        // },
        {
          name: '2',
          label: '设计输入',
          icon: 'ios-people',
          children: [
            {
              name: '2-1',
              label: '网络系统图',
              icon: 'md-photos',
              children: [
                {
                  name: 'networkServerSystem',
                  label: '单交接箱',
                  icon: 'md-photos'
                },
                {
                  name: 'networkServerSystem2',
                  label: '双交接箱',
                  icon: 'md-photos'
                },
                {
                  name: 'batchUploadExecl',
                  label: '批量导入',
                  icon: 'md-photos'
                }
              ]
            },
            {
              name: 'kmlManage',
              label: '光缆线路图',
              icon: 'md-photos'
            },
            {
              name: '2-3',
              label: '宽带光缆分布图',
              icon: 'md-photos',
              children: [
                {
                  name: 'fbt',
                  label: '288芯',
                  icon: 'md-photos'
                },
                {
                  name: 'fbt2',
                  label: '576芯',
                  icon: 'md-photos'
                }
              ]
            }
          ]
        },
        // {
        //   name: 'kmlManage',
        //   label: '设计输入',
        //   icon: 'md-photos'
        // },
        // {
        //   name: 'excelManage',
        //   label: '施工图纸生成',
        //   icon: 'md-photos'
        // },
        // {
        //   name: 'networkServerSystem',
        //   label: '网络系统图(单交接箱)',
        //   icon: 'md-photos'
        // },
        // {
        //   name: 'networkServerSystem2',
        //   label: '网络系统图(双交接箱)',
        //   icon: 'md-photos'
        // },
        // {
        //   name: 'fbt',
        //   label: '宽带光缆分布图(288芯)',
        //   icon: 'md-photos'
        // },
        // {
        //   name: 'fbt2',
        //   label: '宽带光缆分布图(576芯)',
        //   icon: 'md-photos'
        // },
        {
          name: 'contrastManage',
          label: '图标对比',
          icon: 'md-cloudy'
        },
        
        {
          name: 'historyManage',
          label: '历史记录',
          icon: 'md-cloudy',
          children: [
            {
              name: 'historyManage',
              label: '线路图记录',
              icon: 'md-photos',
            },{
              name: 'systemHistory',
              label: '系统图记录',
              icon: 'md-photos',
            }]
        },
      ]
    }
  }
}
</script>
